package system;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 文件项对象
 *
 * @author waxijiang
 */
public class FileItem implements Serializable {
    /**
     * 文件名，最大10个字节
     */
    private String filename;
    /**
     * 索引节点, 2个字节(指针)
     */
    private Disk.Inode inode;

    public FileItem(String filename, String fileType, int fileSize, int userPermission, int otherPermission,
                    Date createTime,
                    Date updateTime, String own, int firstFileBlockIndex, Disk.InodeBlock inodeBlock) {
        this.filename = filename;
        List<Integer> fileBlockIndex = new ArrayList<Integer>();
        fileBlockIndex.add(firstFileBlockIndex);
        this.inode = inodeBlock.getInode(fileType, fileSize, userPermission, otherPermission, createTime, updateTime,
                own, fileBlockIndex);
    }

    public FileItem(String filename, Disk.Inode inode) {
        this.filename = filename;
        this.inode = inode;
    }

    public String getFilename() {
        return filename;
    }

    public void setFilename(String filename) {
        this.filename = filename;
    }

    public Disk.Inode getInode() {
        return inode;
    }

    public int getUserPermission(){
        return inode.userPermission;
    }

    public int getOtherPermission(){
        return inode.otherPermission;
    }

    public String getOwn(){
        return inode.own;
    }

    public int getSize(){
        return inode.fileSize;
    }

    public Date getCreateTime(){
        return inode.createTime;
    }

    public String getFileType(){
        return inode.getFileType();
    }

    public void setInode(Disk.Inode inode){
        this.inode = inode;
    }

}
